/**
 * Alipay.com Inc.
 * Copyright (c) 2004-2011 All Rights Reserved.
 */
package com.alipay.supergw.common.dal.share_supergw.auto.ibatis;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.dao.DataAccessException;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

import com.alipay.supergw.common.dal.share_supergw.auto.daointerface.ValidationTemplateDAO;
import com.alipay.supergw.common.dal.share_supergw.auto.dataobject.ValidationTemplateDO;

/**
 * An ibatis based implementation of dao interface <tt>com.alipay.supergw.common.dal.share_supergw.auto.daointerface.ValidationTemplateDAO</tt>.
 *
 * This file is generated by <tt>supergw-dalgen</tt>, a DAL (Data Access Layer)
 * code generation utility specially developed for <tt>supergw</tt> project.
 * 
 * PLEASE DO NOT MODIFY THIS FILE MANUALLY, or else your modification may
 * be OVERWRITTEN by someone else. To modify the file, you should go to 
 * directory <tt>(project-home)/dalgen</tt>, and 
 * find the corresponding configuration file (<tt>tables/sgw_validation_template.xml</tt>). 
 * Modify the configuration file according to your needs, then run <tt>supergw-dalgen</tt> 
 * to generate this file.
 */
public class IbatisValidationTemplateDAO extends SqlMapClientDaoSupport implements
                                                                       ValidationTemplateDAO {

    /**
     *  Query DB table <tt>sgw_validation_template</tt> for records.
     *
     *  <p>
     *  Description for this operation is<br>
     *  <tt></tt>
     *  <p>
     *  The sql statement for this operation is <br>
     *  <tt>select trans_type_id, message_type, template_content, gmt_create, gmt_modified from sgw_validation_template</tt>
     *
     *	@return List<ValidationTemplateDO>
     *	@throws DataAccessException
     */
    @SuppressWarnings("unchecked")
    public List<ValidationTemplateDO> loadAll() throws DataAccessException {

        return getSqlMapClientTemplate().queryForList("MS-VALIDATION-TEMPLATE-LOAD-ALL", null);

    }

    /**
     *  Insert one <tt>ValidationTemplateDO</tt> object to DB table <tt>sgw_validation_template</tt>, return primary key
     *
     *  <p>
     *  Description for this operation is<br>
     *  <tt></tt>
     *  <p>
     *  The sql statement for this operation is <br>
     *  <tt>insert into sgw_validation_template(trans_type_id,template_content,message_type,gmt_create,gmt_modified) values (?, ?, ?, sysdate, sysdate)</tt>
     *
     *	@param validationTemplate
     *	@return String
     *	@throws DataAccessException
     */
    public String insert(ValidationTemplateDO validationTemplate) throws DataAccessException {
        if (validationTemplate == null) {
            throw new IllegalArgumentException("Can't insert a null data object into db.");
        }

        getSqlMapClientTemplate().insert("MS-VALIDATION-TEMPLATE-INSERT", validationTemplate);

        return validationTemplate.getTransTypeId();
    }

    /**
     *  Update DB table <tt>sgw_validation_template</tt>.
     *
     *  <p>
     *  Description for this operation is<br>
     *  <tt></tt>
     *  <p>
     *  The sql statement for this operation is <br>
     *  <tt>update sgw_validation_template set template_content=?, message_type=?, gmt_modified=sysdate where ((trans_type_id = ?))</tt>
     *
     *	@param templateContent
     *	@param messageType
     *	@param transTypeId
     *	@return int
     *	@throws DataAccessException
     */
    @SuppressWarnings( { "rawtypes", "unchecked" })
    public int update(String templateContent, String messageType, String transTypeId)
                                                                                     throws DataAccessException {
        Map param = new HashMap();

        param.put("templateContent", templateContent);
        param.put("messageType", messageType);
        param.put("transTypeId", transTypeId);

        return getSqlMapClientTemplate().update("MS-VALIDATION-TEMPLATE-UPDATE", param);
    }

    /**
     *  Query DB table <tt>sgw_validation_template</tt> for records.
     *
     *  <p>
     *  Description for this operation is<br>
     *  <tt></tt>
     *  <p>
     *  The sql statement for this operation is <br>
     *  <tt>select trans_type_id, template_content, message_type, gmt_create, gmt_modified from sgw_validation_template where ((trans_type_id = ?) AND (message_type = ?))</tt>
     *
     *	@param transTypeId
     *	@param messageType
     *	@return List<ValidationTemplateDO>
     *	@throws DataAccessException
     */
    @SuppressWarnings( { "rawtypes", "unchecked" })
    public List<ValidationTemplateDO> select(String transTypeId, String messageType)
                                                                                    throws DataAccessException {
        Map param = new HashMap();

        param.put("transTypeId", transTypeId);
        param.put("messageType", messageType);

        return getSqlMapClientTemplate().queryForList("MS-VALIDATION-TEMPLATE-SELECT", param);

    }

    /**
     *  Delete records from DB table <tt>sgw_validation_template</tt>.
     *
     *  <p>
     *  Description for this operation is<br>
     *  <tt></tt>
     *  <p>
     *  The sql statement for this operation is <br>
     *  <tt>delete from sgw_validation_template where ((trans_type_id = ?) AND (message_type = ?))</tt>
     *
     *	@param transTypeId
     *	@param messageType
     *	@return int
     *	@throws DataAccessException
     */
    @SuppressWarnings( { "rawtypes", "unchecked" })
    public int delete(String transTypeId, String messageType) throws DataAccessException {
        Map param = new HashMap();

        param.put("transTypeId", transTypeId);
        param.put("messageType", messageType);

        return getSqlMapClientTemplate().delete("MS-VALIDATION-TEMPLATE-DELETE", param);
    }

}